package top.hkyzf.study.leetcode.array;

import org.junit.Test;

import java.util.Arrays;

/**
 * @author 朱峰
 * @date 2022-2-11 10:12
 */
public class 合并两个有序数组_88 {
    public void merge(int[] nums1, int m, int[] nums2, int n) {
        if (nums1.length == 0) {
            nums1 = nums2;
        }
        if (nums2.length == 0) {
            return;
        }
        for (int i = 0; i < n; i++) {
            int index = i+m;
            nums1[index] = nums2[i];
        }
        Arrays.sort(nums1);
    }

    @Test
    public void testMerge () {
        int m = 3;
        int n = 3;
        int[] nums1 = {1,2,3,0,0,0};
        int[] nums2 = {2,5,6};
        merge(nums1, m, nums2, n);
        System.out.println(Arrays.toString(nums1));
    }
}
